using System;
using System.Drawing;

using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace Socialite
{
	public partial class StartupScreen : UIViewController
	{
		//View controller for the user name and password input...
		private LoginScreen _loginScreen;
		private SignupScreen _signupScreen;
		
		public StartupScreen () : base ("StartupScreen", null)
		{
			//When this view is pushed onto a navigation controller, 
			//hide the tab bar
			HidesBottomBarWhenPushed = true;
			
			Title = NSBundle.MainBundle.LocalizedString ("Socialite", "Socialite");
			TabBarItem.Image = UIImage.FromBundle ("Images/first");
			_loginScreen = new LoginScreen ();
			_signupScreen = new SignupScreen ();
		}
		
		public override void DidReceiveMemoryWarning ()
		{
			// Releases the view if it doesn't have a superview.
			base.DidReceiveMemoryWarning ();
			
			// Release any cached data, images, etc that aren't in use.
		}
		
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			// Perform any additional setup after loading the view, typically from a nib.
			LoginButton.TouchUpInside += (sender, e) => 
			{
				if (this._loginScreen == null) { 
					this._loginScreen = new LoginScreen ();
				}
				//---- push our hello world screen onto the navigation
				//controller and pass a true so it navigates
				this.NavigationController.PushViewController (this._loginScreen, true);
		
			};
			
			// Perform any additional setup after loading the view, typically from a nib.
			SignupButton.TouchUpInside += (sender, e) => 
			{
				if (this._signupScreen == null) { 
					this._signupScreen = new SignupScreen ();
				}
				//---- push our hello world screen onto the navigation
				//controller and pass a true so it navigates
				this.NavigationController.PushViewController (this._signupScreen, true);
		
			};
		}
		
		public override void ViewDidUnload ()
		{
			base.ViewDidUnload ();
			
			// Clear any references to subviews of the main view in order to
			// allow the Garbage Collector to collect them sooner.
			//
			// e.g. myOutlet.Dispose (); myOutlet = null;
			
			ReleaseDesignerOutlets ();
		}
		
		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);
			this.NavigationController.SetNavigationBarHidden (true, animated);
			this.TabBarController.TabBar.Hidden = true;
		}
		
		public override void ViewWillDisappear (bool animated)
		{
			base.ViewWillDisappear (animated);
			this.NavigationController.SetNavigationBarHidden (false, animated);
			this.TabBarController.TabBar.Hidden = true;
		}

		public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
		{
			// Return true for supported orientations
			return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
		}
	}
}

